package com.sun.spring5.annotations;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringTest {
    @Test
    public void test01(){
        ApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class);
        Object son = context.getBean(Person.class);
        System.out.println(son);
        int i = context.getBeanDefinitionCount();
        System.out.println(i);
        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
        String[] types = context.getBeanNamesForType(Person.class);
        for (String name : types) {
            System.out.println(name);
        }
    }

    @Test
    public void test02(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig2.class);
        Object person = context.getBean("person");
        context.close();
    }
    @Test
    public void test03(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig3.class);

        context.close();
    }
}
